package classes.view.component 
{
	import classes.controller.EDataObject;
	
	import com.greensock.TweenMax;
	import com.greensock.easing.Cubic;
	
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.external.ExternalInterface;
	import flash.text.TextField;
	
	import com.d4p.custom.customScrollBar.Scrollbar;

	public class PopupScoreItem extends MovieClip
	{
		private var _data_obj:Object;
		private var _levelup:MovieClip;
		private var _no_text:TextField;
		private var _nick_text:TextField;
		private var _levelMC:MovieClip;
		private var _ok_text:TextField;
		private var _score_text:TextField;
		private var _rank_text:TextField;
		private var _rankMC:MovieClip;
		
		public var _bg:MovieClip;
		
		public function PopupScoreItem() 
		{
			super();
			setLayOut();
			initListener();
			defaultSetting();
		}
		
		private function setLayOut():void
		{
			this._levelup	=	this.getChildByName('levelup_mc') 		as MovieClip;
			this._no_text	=	this.getChildByName('no_txt') 	 		as TextField;
			this._nick_text	=	this.getChildByName('nick_txt') 	  	as TextField;
			this._levelMC	=	this.getChildByName('level_mc') 		as MovieClip;
			this._ok_text	=	this.getChildByName('ok_txt') 	 		as TextField;
			this._score_text=	this.getChildByName('score_txt') 	  	as TextField;
			this._rank_text	=	this.getChildByName('rank_txt') 	  	as TextField;
			this._rankMC	=	this.getChildByName('rank_mc') 			as MovieClip;
			this._bg		= 	this.getChildByName('bg_mc')			as MovieClip;
		}
		
		private function initListener():void
		{
			//this._select_mc.addEventListener(MouseEvent.ROLL_OVER, listOver);
		}
		
		private function defaultSetting():void
		{
			_levelup.visible = false;
			//TweenMax.to(_select_mc, 0, { autoAlpha:0 } );
		}
		
		public function data_init($data:*, $num:*):void
		{
			_data_obj = $data;
			
			_no_text.text = String($num + 1);
			
			_nick_text.text = _data_obj.nick;
			var a:Number = Number(_data_obj.nowLevel);
			_levelMC.text_txt.text = String(_data_obj.nowLevel);
			_levelMC.text_txt.x = -2;
			if (a >= 50) {
				_levelMC.bg_mc.gotoAndStop(6);
			} else if (a >= 40) {
				_levelMC.bg_mc.gotoAndStop(5);
			} else if (a >= 30) {
				_levelMC.bg_mc.gotoAndStop(4);
			} else if (a >= 20) {
				_levelMC.bg_mc.gotoAndStop(3);
			} else if (a >= 10) {
				_levelMC.bg_mc.gotoAndStop(2);
			} else {
				_levelMC.text_txt.x = -4;
				_levelMC.bg_mc.gotoAndStop(1);
			}
			
			
			
			if (Number(_data_obj.isLevelUp) == 1) {
				_levelup.visible = true;
			}
			
			_ok_text.text = _data_obj.currect + " / " + _data_obj.totalAnswer + " (" + Number(_data_obj.currect / _data_obj.totalAnswer * 100).toFixed(0) + "%)";
			_score_text.text = _data_obj.thisScore + " / " + _data_obj.totalScore;
			_rank_text.text = String(_data_obj.nowLevel);
			
			_rankMC.gotoAndStop(2);
			_rankMC.text_txt.text = String(_data_obj.varyRank);
			//win_txt = _data_obj.id;
			
			/*
			 * 승패데이타 필요함
			 */
		}

		
		
		
//"id":"아이디" //아이디
//,"nick":"닉네임" //닉네임
//,"thisRank":1 //게임등수
//,"totalRank":1231234 //전체등수
//,"thisScore":1231344 //게임점수
//,"totalScore":123556645 //전체점수
//,"isLevelUp":1 //레벨업여부  1:true, 0:false
//,"currect":20 //맞힌문제
//,"totalAnswer":20 //푼문제
//,"nowLevel":12 //레벨
//,"varyRank":12 //순위변동
	}

}